home *** CD-ROM | disk | FTP | other *** search
- ;void translate(strg,table);
- ; char *strg,*table;
-
- EXTRN _memory_model:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _translate
- _translate proc near
- push bp ;
- mov bp,sp ;set stack frame
- push di ;
- push ds ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- les di,dword ptr[bp+4] ;ES:DI pts to the strg
- lds bx,dword ptr[bp+8] ;DS:BX pts to the table
- jmp short L1 ;
- L0: mov di,[bp+4] ;NEAR case
- mov bx,[bp+6] ;
- mov ax,ds ;ES = DS
- mov es,ax ;
- L1: mov al,es:[di] ;get a character
- cmp al,0 ;end of string?
- je L2 ;quit if so
- xlat [bx] ;translate
- mov es:[di],al ;change the character
- inc di ;forward Strg pointer
- jmp short L1 ;go do next char
- L2: pop ds ;
- pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _translate ENDP
- _TEXT ENDS
- END